package com.yanqu.road.server.cmd.activity.businessreunion;

import com.yanqu.road.pb.activity.BusinessReunionProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.businessreunion.BusinessReunionActivityModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2022/4/19 11:50
 */
@Cmd(code = GameProtocol.S_CROSS_RECALL_BIND_RESP, desc = "跨服召回绑定返回")
public class CrossRecallBindRespCmd extends AbstractCommand {
    private int bindRet;
    private String recallCode = "";
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        BusinessReunionProto.WriteRecallCodeRespCrossMsg respMsg = BusinessReunionProto.WriteRecallCodeRespCrossMsg.parseFrom(packet.getBytes());
        bindRet = respMsg.getRet();
        recallCode = respMsg.getRecallCode();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        if (bindRet == 0) {
            player.getModule(BusinessReunionActivityModule.class).recallBindSuccess(recallCode);
        }
        player.getModule(BusinessReunionActivityModule.class).resetPreBind();
    }

    @Override
    public void sendData(GamePlayer player) {
    }
}
